package leetcode;

import java.util.HashMap;
import java.util.Map;

public class RepeatedCharacter {
    public static void main(String[] args) {
        RepeatedCharacter repeatedCharacter = new RepeatedCharacter();
        System.out.println(repeatedCharacter.repeatedCharacter("abcdd"));
    }
    public char repeatedCharacter(String s) {
        char[] chars = s.toCharArray();
        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < chars.length; i++) {
            if (map.containsKey(chars[i])) {
                return chars[i];
            } else {
                map.put(chars[i], i);
            }
        }
        return s.charAt(0);
    }
}
